<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #canvas {
            background: rebeccapurple;
        }
    </style>
</head>
<body>

<canvas id="canvas" width="700" height="800"></canvas>

<script>
    const canvas = document.getElementById('canvas')
    // canvas.width = 300
    // canvas.height = 1000

    //画笔
    const ctx = canvas.getContext('2d')
    //填充矩形
    ctx.fillRect(200, 100, 200, 300)
    //描边矩形
    ctx.strokeStyle = 'red'
    ctx.lineWidth = 10
    ctx.strokeRect(200, 100, 200, 300)
    //清理矩形方法
    ctx.clearRect(200, 100, 200, 300)
    // ctx.clearRect(0, 0, canvas.width, canvas.height)

</script>
</body>
</html>
